package StudyCode.summary.mycollection;

import java.util.ArrayList;
import java.util.Collections;

/**
 * 版权所有 科技与人文(www.tah1986.com)
 */
public class PerformBinarySearchOnArrayList {
	public static void main(String[] args) {
		ArrayList arrayList = new ArrayList();

		arrayList.add("1");
		arrayList.add("4");
		arrayList.add("2");
		arrayList.add("5");
		arrayList.add("3");
		Collections.sort(arrayList);
		System.out.println("ArrayList 排序后元素 : " + arrayList);

		int index = Collections.binarySearch(arrayList, "4");

		System.out.println("二分法查找 4 的索引是 : " + index);
	}
}
